home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 25
/
Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso
/
Aminet
/
dev
/
amos
/
AMOS0398.lzh
/
AMOSLIST
/
000328_amos-request@svcs1.digex.net_Tue Mar 31 00:05:13 1998.msg
< prev
next >
Wrap
Text File
|
1998-04-01
|
5KB
|
147 lines
>From amos-request@svcs1.digex.net Tue Mar 31 00:05:13 1998
Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
by pony-1.mail.digex.net (8.8.8/8.8.8) with ESMTP id AAA09943
for <mcox@access.digex.net>; Tue, 31 Mar 1998 00:05:13 -0500 (EDT)
Received: (from daemon@localhost)
by svcs1.digex.net (8.8.5/8.8.5) id TAA16621
for amos-out; Mon, 30 Mar 1998 19:14:54 -0500 (EST)
Received: from pony-2.mail.digex.net (pony-2.mail.digex.net [204.91.241.6])
by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id TAA16618
for <amos-list@svcs1.digex.net>; Mon, 30 Mar 1998 19:14:53 -0500 (EST)
Received: from mmi-mailrelay.ModusMedia.com (firefox.modusmedia.com [208.14.214.2])
by pony-2.mail.digex.net (8.8.8/8.8.8) with ESMTP id TAA22498
for <amos-list@access.digex.net>; Mon, 30 Mar 1998 19:14:52 -0500 (EST)
From: Declan_Gorman@modusmedia.com
Received: from smtp2.modusmedia.com ([192.168.131.84])
by mmi-mailrelay.ModusMedia.com (Post.Office MTA v3.1
release PO205e ID# 0-0U10L2S100) with SMTP id AAA157
for <amos-list@access.digex.net>; Mon, 30 Mar 1998 16:46:03 -0700
Received: from ccMail by smtp2.modusmedia.com
(IMA Internet Exchange 3.0 Enterprise) id 0000E383; Mon, 30 Mar 98 16:39:45 -0700
Mime-Version: 1.0
Date: Mon, 30 Mar 1998 09:21:57 -0700
Message-ID: <0000E383.eval@modusmedia.com>
Subject: Re[2]: Sorting Problem
To: Rune Zedeler <rzedeler@post10.tele.dk>
Cc: AMOS List <amos-list@access.digex.net>
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Description: cc:Mail note part
Status: O
X-Status:
Thanks, I will try this out later. One thing I should point out is
that I made a bit of an error when I said 128 blocks of 256k. This
should read 128 of 256 bytes. Would this have much effect on the code
provided below?
______________________________ Reply Separator _________________________________
Subject: Re: Sorting Problem
Author: Rune Zedeler <rzedeler@post10.tele.dk> at Internet
Date: 27/03/98 20:50
On 16-Mar-98, Declan_Gorman@modusmedia.com wrote:
> My program has a memory bank which consists of 128 blocks of memory,
> each 256k in size. Each memory block has a name and category and I
> want to be able to sort the bank by either.
This should do it:
<CUT>
' Needs sorting string to be located in S_STR$(0) to S_STR$(NUM-1)
' ( ... I don't know how to pass arrays to procs...)
_SORT[128,256*1024,BANK_NUMBER,NUMBER_OF_ITEMS_IN_ARRAY,UNUSED_BANK]
Procedure _SORT[NUM,SIZ,BNK,ARR_SIZ,TMP_BNK]
Shared S_STR$()
Reserve As Work TMP_BNK,SIZ
Dim CUR(NUM-1),OLD(NUM-1)
'Add number of item to the end of the string
For I=0 To NUM-1 : S_STR$(I)=S_STR$(I)+Hex$(I,4) : Next I
'ensure that unused items in array will be placed first after sorting
If ARR_SIZ>NUM
For I=NUM To ARR_SIZ-1 : S_STR$(I)='' : Next I
End If
Sort S_STR$(0)
'move sorted items FROM last TO first in array
For I=0 To NUM-1 : S_STR$(I)=S_STR$(I+ARR_SIZ-NUM) : Next I
'At this point the first NUM indexes in S_STR$() contains sorted
'data - followed by the original position in the array.
For I=0 To NUM-1 : CUR(I)=I : OLD(I)=I : Next I
'CUR(ORIGINAL_POS) contains CURRENT_POS
'OLD(CURRENT_POS) contains ORIGINAL_POS
For I=0 To NUM-1
'OLDI=what index index I had before sorting.
OLDI=Val(Right$(S_STR$(I),5))
'J=Current position of block
J=CUR(OLDI)
Print OLDI,J
S_STR$(I)=Left$(S_STR$(I),Len(S_STR$(I))-5)
'swap blocks:
If I<>J
Copy Start(BNK)+I*SIZ,Start(BNK)+(I+1)*SIZ To Start(TMP_BNK)
Copy Start(BNK)+J*SIZ,Start(BNK)+(J+1)*SIZ To Start(BNK)+I*SIZ
Copy Start(TMP_BNK),Start(TMP_BNK)+SIZ To Start(BNK)+J*SIZ
Swap CUR(OLD(I)),CUR(OLD(J))
Swap OLD(I),OLD(J)
End If
Next I
Erase TMP_BNK
End Proc
<CUT>
Quick tech explanation (hmmm, how it works, eh):
I use the internal AMOS sort cmd. But before sorting I add the hex number to
the end of the strings. So if the strings are:
Hi
There
!!!
then I add like this:
Hi$0000
There$0001
!!!$0002
After sorting (using "Sort") it is:
!!!$0002
Hi$0000
There$0001
- and I can use the numbers to move around in the bank.
I reserve a temp bank on the size of one block (that is 256k)
As I do not have 32MB of ram I have not been able to test it with your amount
of memory. It moves the memory three times. That is: It will move 96MB of
data! So it'll probably use a small amount of time.
Just write a letter to the list (send a copy to me personally, as I am only
very seldom at home and therefore incidentally skips some letters in the
mailinglists) if you have questions.
--
/?\ __ __ /?????\ _ Rune Zedeler
________/ /// \\__/ \\\ ---/ \?-_ Peter Rordams Vej 19
\ / //?| \\/ ||?\ \\?????????????? ?-_ 2800 Lyngby
) / // | \ ` / || \ \\ Lemmus of Efreet - Denmark
/ / ?????\\|\-'/ /????? \\____________ _-?
?????\------'/||??| \------'/ /_-? rzedeler@post10.tele.dk
??????\-'/ \-'/?????? ? Tel: +45-45871730
?? ??